
import 'package:valovault_reminder/common/config/val_client_url_path.dart';
import 'package:valovault_reminder/common/ui/val_ui_kit_dialog_impl.dart';
import 'package:valovault_reminder/http/val_dio_fetch_kit.dart';
import 'package:valovault_reminder/util/val_toast_kit.dart';

typedef FinishCallback = void Function(bool result);

class ValHttpWorker {
  /// 消费金币
  static void requestCoinCostResource({required double outlay, FinishCallback? finishCallback}) async {
    ValUIKitDialogImpl.showProgress();
    Map<String, dynamic> params = {"outlay": outlay, "source": "iap"};

    ValDioFetchKit.getInstance().postJsonWithUrl(ValClientUrlPath.reviewModeConsume, params,
            (data, errorCode, message) {
      // print('========$data===');
      // print('========$errorCode===');
      // print('========$message===');
          ValUIKitDialogImpl.hideProgress();
          if (finishCallback != null) {
            finishCallback(errorCode == 0);
          }
          if (errorCode != 0) {
            ValToastKit.showMessage(message);
          }
        }, (err) {
          ValUIKitDialogImpl.hideProgress();
          if (finishCallback != null) {
            finishCallback(false);
          }
        });
  }
}